package www.dianbaozu.com.ui.chat.refuseList.adapter

import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder
import com.netease.nim.uikit.databinding.ItemFriendRefuseBinding
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo

class RefuseListAdapter(
    recyclerView: RecyclerView,
    layoutId: Int,
    data: List<NimUserInfo>,
    private val onItemClick: OnItemClick
) :
    BaseQuickAdapter<NimUserInfo, BaseViewHolder>(recyclerView, layoutId, data) {
    private var binding: ItemFriendRefuseBinding? = null

    override fun convert(
        helper: BaseViewHolder,
        item: NimUserInfo,
        position: Int,
        isScrolling: Boolean
    ) {
        binding = DataBindingUtil.bind(helper.itemView)
        binding?.apply {
            ivAvatar.loadBuddyAvatar(item.account)
            tvNickname.text = item.name
            tvUnblock.setOnClickListener { onItemClick.unlock(helper.layoutPosition, item) }
        }
    }

    fun interface OnItemClick {
        fun unlock(position: Int, item: NimUserInfo)
    }
}